<?php
 /*Template Name: Project Category
 */
 

$categories = get_project_categories();		
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );

	

get_header(); ?>

<div class="container" id="top_info">
	<div class="top-content">&nbsp;</div>
    <div class="top-curve">&nbsp;</div>
</div>


<div class="container">
	 <?php 
		$p = get_page_by_title( 'Projects' );
		$sliders = get_post_meta($p->ID, 'dmci_sliders', true);
		$slider_title = get_post_meta($p->ID, 'dmci_slider_title', true);
		$slider_desc = get_post_meta($p->ID, 'dmci_slider_desc', true);
		if( $sliders ):
		$sliders = json_decode(htmlspecialchars_decode($sliders), true);
	
	?>
	<div class="page-slider-wrapper">
    <div class="page-slider">
		
		<?php foreach($sliders as $slide) :?>
        <div class="slide">
        	<img src="<?php echo $slide; ?>" alt="image1" />
        </div>		
		<?php endforeach;?>
        
    </div>
	<div class="slider-text">
        <div class="title"><?php echo $slider_title; ?></div>
     	<div class="desc"><?php echo $slider_desc; ?></div>
    </div>
    </div>
	<?php else: ?>
		<div class="page-filler">&nbsp;</div>
	<?php endif; ?>
    
   
    
    <div class="page-content">
      
    	<div class="proj-cat">
       		<h3><?php echo $term->name; ?></h3>
			<div class="proj-desc"><?php echo $term->description; ?></div>
			<div class="clear">&nbsp;</div>
            <?php 
				$query = get_project_category_posts('dmci_projects', 'dmci_project_categories', $term->slug, 1);
				while ( $query->have_posts() ) :
					$query->the_post();
					$image = get_post_meta($post->ID, 'dmci_sliders', true);
				?>
                <div class="info">
						<?php 
							
							$image = json_decode(htmlspecialchars_decode($image), true);
							if( isset($image[0]) ): 
						?>
                        <a href="<?php echo the_permalink()?>" class="img-link">
                        	<img src="<?php echo $image[0]?>" alt="image2" />
                        </a>
						<?php endif; ?>
                       <div class="text">
                            <p><strong><?php echo the_title(); ?></strong></p>
                            <div class="exceprt"><?php the_excerpt(); ?></div>
                            <a href="<?php echo the_permalink(); ?>">Explore Project</a>
                        </div>
                        <div class="clear">&nbsp;</div>
                    </div>   
                <?php	endwhile; ?>
               	<ul class="listings">
                	<?php 
					$query = get_project_category_posts('dmci_projects', 'dmci_project_categories', $term->slug);
					$ctr = 0;
					while ( $query->have_posts() ) :
						$query->the_post();
					?>
                    <?php if( $ctr > 0) : ?>
					<li><a href="<?php the_permalink(); ?>"><span class="arrow">&gt;</span><?php the_title(); ?></a></li>
                    <?php 
						endif; 
						$ctr++;
					
					?>
                    <?php endwhile; ?>
                </ul>
                <div class="clear">&nbsp;</div>
        </div>
        <?php 
		
			wp_reset_postdata();
		?>
        
  		
    </div>
   
</div>




<?php wp_reset_query(); ?>
<?php get_footer(); ?>